package com.ot.flink.cdc.function;

import com.ot.flink.cdc.biz.domain.CdcTask;
import com.ot.flink.cdc.biz.service.TaskService;
import com.ot.flink.cdc.common.TaskStatusEnum;
import com.ot.flink.cdc.config.CdcJdbcConfig;
import com.ot.flink.cdc.function.mapper.MapperFactory;
import com.ot.flink.cdc.function.sink.SinkFactory;
import com.ot.flink.cdc.function.source.CdcSourceFactory;
import com.ot.flink.cdc.util.EnvUtil;
import com.ot.flink.cdc.util.SpringUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.core.execution.JobClient;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author: pangtt
 * @date: 2023/9/24
 * @since JDK1.8 version: 1.0.0
 */
@Component
public class CdcRunner implements CommandLineRunner, DisposableBean {

    /** 日志 */
    private static Logger logger = LoggerFactory.getLogger(CdcRunner.class);

    @Autowired
    private CdcHolder cdcHolder;

    @Override
    public void run(String... args) throws Exception {
        cdcHolder.initEvn();
        cdcHolder.start();
    }

    @Override
    public void destroy() throws Exception {
        cdcHolder.close();
    }

}
